/**
 * amis v6.13.0
 * build time: 2025-08-12
 * Copyright 2018-2025 baidu
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _withRemoteConfig = require('amis-ui/lib/withRemoteConfig');
var _Steps = require('amis-ui/lib/components/Steps');
var tslib = require('tslib');
var React = require('react');
var amisCore = require('amis-core');
var isPlainObject = require('lodash/isPlainObject');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _withRemoteConfig__default = /*#__PURE__*/_interopDefaultLegacy(_withRemoteConfig);
var _Steps__default = /*#__PURE__*/_interopDefaultLegacy(_Steps);
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
var isPlainObject__default = /*#__PURE__*/_interopDefaultLegacy(isPlainObject);

var __react_jsx__ = require('react');
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;


;function StepsCmpt(props) {
  var _a;
  var className = props.className,
    style = props.style,
    steps = props.steps,
    status = props.status,
    mode = props.mode,
    iconPosition = props.iconPosition,
    labelPlacement = props.labelPlacement,
    progressDot = props.progressDot,
    data = props.data,
    source = props.source,
    render = props.render,
    mobileUI = props.mobileUI,
    iconClassName = props.iconClassName,
    titleClassName = props.titleClassName,
    subTitleClassName = props.subTitleClassName,
    descriptionClassName = props.descriptionClassName;
  var sourceResult = amisCore.resolveVariableAndFilter(source, data, '| raw');
  /** 步骤数据源 */
  var stepsRow = (Array.isArray(sourceResult) ? sourceResult : undefined) || steps || [];
  /** 状态数据源 */
  var statusValue = amisCore.isPureVariable(status) ? amisCore.resolveVariableAndFilter(status, data, '| raw') : status;
  var resolveRender = function (val) {
    return typeof val === 'string' ? amisCore.filter(val, data) : val && render('inner', val);
  };
  var value = (_a = amisCore.getPropValue(props)) !== null && _a !== void 0 ? _a : 0;
  var resolveValue = typeof value === 'string' && isNaN(+value) ? amisCore.resolveVariable(value, data) || value : +value;
  var valueIndex = stepsRow.findIndex(function (item) {
    return item.value && item.value === resolveValue;
  });
  var currentValue = valueIndex !== -1 ? valueIndex : resolveValue;
  var resolveSteps = stepsRow.map(function (step, i) {
    var stepStatus = getStepStatus(step, i);
    return tslib.__assign(tslib.__assign({}, step), {
      status: stepStatus,
      title: resolveRender(step.title),
      subTitle: resolveRender(step.subTitle),
      description: resolveRender(step.description)
    });
  });
  function getStepStatus(step, i) {
    var stepStatus;
    if (typeof statusValue === 'string') {
      if (i === currentValue) {
        stepStatus = statusValue || status || _Steps.StepStatus.process;
      }
    } else if (typeof statusValue === 'object') {
      var key = step.value;
      key && statusValue[key] && (stepStatus = statusValue[key]);
    }
    return stepStatus;
  }
  return _J$X_(_Steps__default["default"], {
    current: currentValue,
    steps: resolveSteps,
    className: className,
    iconClassName: iconClassName,
    subTitleClassName: subTitleClassName,
    titleClassName: titleClassName,
    descriptionClassName: descriptionClassName,
    style: style,
    status: statusValue,
    mode: mode,
    iconPosition: iconPosition,
    progressDot: progressDot,
    labelPlacement: labelPlacement,
    mobileUI: mobileUI
  });
}
var StepsWithRemoteConfig = _withRemoteConfig__default["default"]()(/** @class */function (_super) {
  tslib.__extends(class_1, _super);
  function class_1() {
    return _super !== null && _super.apply(this, arguments) || this;
  }
  class_1.prototype.render = function () {
    var _a = this.props,
      cx = _a.classnames,
      config = _a.config,
      deferLoad = _a.deferLoad,
      loading = _a.loading,
      updateConfig = _a.updateConfig,
      id = _a.id,
      wrapperCustomStyle = _a.wrapperCustomStyle,
      env = _a.env,
      themeCss = _a.themeCss,
      className = _a.className,
      ns = _a.classPrefix,
      rest = tslib.__rest(_a, ["classnames", "config", "deferLoad", "loading", "updateConfig", "id", "wrapperCustomStyle", "env", "themeCss", "className", "classPrefix"]);
    var sourceConfig = isPlainObject__default["default"](config) ? config : null;
    return _J$X_(React__default["default"].Fragment, null, _J$X_(StepsCmpt, tslib.__assign({}, rest, sourceConfig, {
      className: cx("".concat(ns, "StepsControl"), className, amisCore.setThemeClassName(tslib.__assign(tslib.__assign({}, this.props), {
        name: 'baseControlClassName',
        id: id,
        themeCss: themeCss
      }))),
      iconClassName: amisCore.setThemeClassName(tslib.__assign(tslib.__assign({}, this.props), {
        name: ['iconControlClassNameDefault', 'iconControlClassNameFinish', 'iconControlClassNameProcess', 'iconControlClassNameWait', 'iconControlClassNameError'],
        id: id,
        themeCss: themeCss
      })),
      subTitleClassName: amisCore.setThemeClassName(tslib.__assign(tslib.__assign({}, this.props), {
        name: ['subTitleControlClassNameDefault', 'subTitleControlClassNameFinish', 'subTitleControlClassNameProcess', 'subTitleControlClassNameWait', 'subTitleControlClassNameError'],
        id: id,
        themeCss: themeCss
      })),
      titleClassName: cx(amisCore.setThemeClassName(tslib.__assign(tslib.__assign({}, this.props), {
        name: ['titleControlClassNameDefault', 'titleControlClassNameFinish', 'titleControlClassNameProcess', 'titleControlClassNameWait', 'titleControlClassNameError'],
        id: id,
        themeCss: themeCss
      }))),
      descriptionClassName: amisCore.setThemeClassName(tslib.__assign(tslib.__assign({}, this.props), {
        name: ['descriptionControlClassNameDefault', 'descriptionControlClassNameFinish', 'descriptionControlClassNameProcess', 'descriptionControlClassNameWait', 'descriptionControlClassNameError'],
        id: id,
        themeCss: themeCss
      }))
    })), _J$X_(amisCore.CustomStyle, tslib.__assign({}, this.props, {
      config: {
        wrapperCustomStyle: wrapperCustomStyle,
        id: id,
        themeCss: themeCss,
        classNames: [{
          key: 'baseControlClassName'
        }, {
          key: 'iconControlClassNameDefault',
          weights: {
            default: {
              important: true
            }
          }
        }, {
          key: 'iconControlClassNameFinish',
          weights: {
            default: {
              important: true,
              parent: '.is-finish'
            }
          }
        }, {
          key: 'iconControlClassNameProcess',
          weights: {
            default: {
              important: true,
              parent: '.is-process'
            }
          }
        }, {
          key: 'iconControlClassNameWait',
          weights: {
            default: {
              important: true,
              parent: '.is-wait'
            }
          }
        }, {
          key: 'iconControlClassNameError',
          weights: {
            default: {
              important: true,
              parent: '.is-error'
            }
          }
        }, {
          key: 'subTitleControlClassNameDefault',
          weights: {
            default: {
              important: true
            }
          }
        }, {
          key: 'subTitleControlClassNameProcess',
          weights: {
            default: {
              important: true,
              parent: '.is-process'
            }
          }
        }, {
          key: 'subTitleControlClassNameFinish',
          weights: {
            default: {
              important: true,
              parent: '.is-finish'
            }
          }
        }, {
          key: 'subTitleControlClassNameWait',
          weights: {
            default: {
              important: true,
              parent: '.is-wait'
            }
          }
        }, {
          key: 'subTitleControlClassNameError',
          weights: {
            default: {
              important: true,
              parent: '.is-error'
            }
          }
        }, {
          key: 'titleControlClassNameDefault',
          weights: {
            default: {
              important: true
            }
          }
        }, {
          key: 'titleControlClassNameProcess',
          weights: {
            default: {
              important: true,
              parent: '.is-process'
            }
          }
        }, {
          key: 'titleControlClassNameFinish',
          weights: {
            default: {
              important: true,
              parent: '.is-finish'
            }
          }
        }, {
          key: 'titleControlClassNameWait',
          weights: {
            default: {
              important: true,
              parent: '.is-wait'
            }
          }
        }, {
          key: 'titleControlClassNameError',
          weights: {
            default: {
              important: true,
              parent: '.is-error'
            }
          }
        }, {
          key: 'descriptionControlClassNameDefault',
          weights: {
            default: {
              important: true
            }
          }
        }, {
          key: 'descriptionControlClassNameFinish',
          weights: {
            default: {
              important: true,
              parent: '.is-finish'
            }
          }
        }, {
          key: 'descriptionControlClassNameProcess',
          weights: {
            default: {
              important: true,
              parent: '.is-process'
            }
          }
        }, {
          key: 'descriptionControlClassNameWait',
          weights: {
            default: {
              important: true,
              parent: '.is-wait'
            }
          }
        }, {
          key: 'descriptionControlClassNameError',
          weights: {
            default: {
              important: true,
              parent: '.is-error'
            }
          }
        }]
      },
      env: env
    })));
  };
  return class_1;
}(React__default["default"].Component));
var StepsRenderer = /** @class */function (_super) {
  tslib.__extends(StepsRenderer, _super);
  function StepsRenderer() {
    return _super !== null && _super.apply(this, arguments) || this;
  }
  StepsRenderer.prototype.render = function () {
    return _J$X_(StepsWithRemoteConfig, tslib.__assign({}, this.props));
  };
  StepsRenderer = tslib.__decorate([amisCore.Renderer({
    type: 'steps'
  })], StepsRenderer);
  return StepsRenderer;
}(React__default["default"].Component);

exports.StepsCmpt = StepsCmpt;
exports.StepsRenderer = StepsRenderer;
